﻿@using Coralcode.Adapter.Gather.Entity.Models
@using CoralNode.Core.Entity.Domains.Prototype
@using CoralNode.MvcClient.Helper
@model Coralcode.Adapter.Gather.Entity.Models.GatherInfoModel

@{
    ViewBag.Title = "绑定字段";
}
@Html.IncludePage("CoralAdmin/gather", "_Left")
<!--content-->
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_import"></span><span class="t t_c">采集管理 /<b class="t_small f_no">绑定字段</b></span>
        </div>
        <div id="main" class="data_import_cnt">
            <div class="js_tabcnt">
                <div class="tablelist_style1" data-js="tabellist_style1">
                    @using (Html.BeginForm("bindproperties", "Gather", FormMethod.Post)) {
                        <div class="funsearch p_1 pl_2 pr_2 extra_normal">
                            <div class="form_main">
                                <label class="pt_0-5">绑定原型：</label>
                                <label>
                                    <select class="w_10" id="prototypeSelect" name="prototypeid">
                                        @foreach (PrototypeDomain prototype in ViewBag.Prototypes) {
                                            <option value="@prototype.Id" @if (ViewBag.PrototypeId == @prototype.Id) { @String.Format("selected=selected")         }>@prototype.Title</option>
                                        }
                                    </select>
                                </label>
                                <label class="pt_0-5 pl_1">绑定分类：</label>
                                <label>
                                    <select class="w_10" id="prototypeCategorySelect" name="prototypeCategoryId">
                                        @foreach (PrototypeCategoryDomain prototypecategory in ViewBag.PrototypeCategories) {
                                            <option value="@prototypecategory.Id" @if (ViewBag.PrototypeCategoryId == @prototypecategory.Id) { @String.Format("selected=selected")         }>@prototypecategory.Title</option>
                                        }
                                    </select>
                                </label>
                            </div>
                        </div>
                        <table cellpadding="0" cellspacing="0" class="border-top1">
                            <thead>
                                <tr class="exclude">
                                    <th width="20%">原型字段</th>
                                    <th align="left">采集字段</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><i class="signmark">*</i><strong>节点标题</strong></td>
                                    <td class="td_left">
                                        <div class="select_owner w_14-5 " data-meta="{ btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>',name:'@ViewBag.NodeTitleFormName',value:'@(ViewBag.BindDatas.ContainsKey(0) ? ViewBag.BindDatas[0] : ViewBag.ThisProperties[0].PropertyName)'}">
                                        <ul>
                                            @foreach (GatherSourcePropertyInfoModel thisproperty in ViewBag.ThisProperties)
                                            {
                                                <li data-value="@thisproperty.PropertyName" >@thisproperty.Description</li>
                                            }
                                        </ul>
                                    </div>
                                    </td>
                                </tr>
                                @foreach (PrototypeFieldDomain property in ViewBag.PrototypeFields) {
                                    <tr>
                                        <td>@property.Title</td>
                                        <td>
                                            <div class="select_owner w_14-5 " data-meta="{ btn:'<span class=\'ico ico_slide_down\'></span>' , clickbtn:'<span class=\'ico ico_slide_up\'></span>',name:'@string.Format("{0}_{1}", property.FieldName, property.Id)',value:'@if (ViewBag.BindDatas.ContainsKey(property.Id)){@ViewBag.BindDatas[property.Id]}'}">
                                            <ul>
                                                <li data-value="">无</li>
                                                @foreach (GatherSourcePropertyInfoModel thisproperty in ViewBag.ThisProperties)
                                                {
                                                    <li data-value="@thisproperty.PropertyName">@thisproperty.Description</li>
                                                }
                                            </ul>
                                        </div>
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                        @Html.Hidden("gatherid", Request["gatherid"])
                        @Html.Hidden("collectionId", Request["collectionId"])
                        <div class="global_fun p_2">
                            <input type="submit" class="btn_1" value="提交" />
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $("#prototypeSelect,#prototypeCategorySelect").change(function () {
            window.location = "@Url.Action("binddataproperties", new {gatherid = Request["gatherId"]})&prototypeid=" + $("#prototypeSelect").val() + "&prototypecategoryid=" + $("#prototypeCategorySelect").val() + "&collectionId=@Request.QueryString["collectionId"]";
        });
        $("form").submit(function () {
            if ($("#prototypeCategorySelect").val() == null) {
                alert("请选择原型类别");
                return false;
            }
        });
    </script>
